package com.kob.backend.controller.GPS;

import com.kob.backend.service.gps.GpsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

/**
 * @program: backend
 * @description:
 * @author: mqf
 * @create: 2023-04-21 19:42
 **/
@RestController
@RequestMapping("/gps")
public class GpsController {
    @Autowired
    private GpsService gpsService;

    /**
     * 发送假信号
     * @return
     */
    @GetMapping()
    public Map<String, String> sendInfo(){
        gpsService.sendFakeInfo();
        Map<String,String> map = new HashMap<>();
        map.put("error_message", "success");
        return map;
    }

    /**
     * 返回一个url，为存放前端经纬度的txt文件
     * @return
     * @throws MalformedURLException
     */
    @GetMapping("/getinfo")
    public Map<String,Object> getInfo() throws MalformedURLException {
        String str = "https://packetmqf3.oss-cn-chengdu.aliyuncs.com/file.txt";
        URL url = new URL(str);
        Map<String,Object> res = new HashMap<>();
        res.put("url",url);
        return res;
    }

    /**
     *
     */

}
